package com.tulingxueyuan.mall.modules.pms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tulingxueyuan.mall.common.api.CommonPage;
import com.tulingxueyuan.mall.modules.pms.model.PmsBrand;
import com.tulingxueyuan.mall.modules.pms.mapper.PmsBrandMapper;
import com.tulingxueyuan.mall.modules.pms.service.PmsBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 品牌表 服务实现类
 * </p>
 *
 * @author SiXiaoLong
 * @since 2022-10-13
 */
@Service
public class PmsBrandServiceImpl extends ServiceImpl<PmsBrandMapper, PmsBrand> implements PmsBrandService {

    @Override
    public Page getList(Integer pageNum,Integer pageSize,String keyword) {
        Page<PmsBrand> page = new Page<>(pageNum,pageSize);
//        CommonPage<PmsBrand> restPage = CommonPage.restPage(page);
        LambdaQueryWrapper<PmsBrand> lqw = new LambdaQueryWrapper<>();
        lqw.like(Strings.isNotBlank(keyword),PmsBrand::getName,keyword);
        lqw.orderByDesc(PmsBrand::getSort);

        return this.page(page,lqw);
    }
}
